package genedit.gui;

import genedit.model.Document;
import genedit.model.Package;
import genedit.model.Project;
import genedit.model.graph.GraphElement;
import genedit.model.graph.Link;
import genedit.model.graph.SubdocumentElement;
import genedit.model.graph.classModel.ClassModel;
import genedit.model.graph.classModel.InterfaceModel;

import java.awt.Component;

import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

/**
 * Klasa zadužena za postavljanje izgleda ikonica čvorova stabla.
 * 
 * @author Nikola
 * @version 1.0 18/12/13
 */
public class GProjectTreeCellRendered extends DefaultTreeCellRenderer {

	private static final long serialVersionUID = 1L;

	public GProjectTreeCellRendered() {
	}

	public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel,
			boolean expanded, boolean leaf, int row, boolean hasFocus) {
		super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

		if (value instanceof Project) {
			setIcon(new ImageIcon("resources/icons/tproject.png"));
		} else if (value instanceof Package) {
			setIcon(new ImageIcon("resources/icons/tpackage.png"));
		} else if (value instanceof Document) {
			setIcon(new ImageIcon("resources/icons/tdocument.png"));
		} else if (value instanceof Link) {
			setIcon(new ImageIcon("resources/icons/layer_select_point.png"));
		} else if (value instanceof InterfaceModel) {
			setIcon(new ImageIcon("resources/icons/interface.png"));
		} else if (value instanceof ClassModel) {
			setIcon(new ImageIcon("resources/icons/directory_object_class.png"));
		} else if (value instanceof SubdocumentElement) {
			setIcon(new ImageIcon("resources/icons/set.png"));
		} else if (value instanceof GraphElement) {
			setIcon(new ImageIcon("resources/icons/stock_draw_rectangle_unfilled.png"));
		}

		return this;
	}

}
